﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Specialized;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using Anthony.Library;

using System.Web.UI.HtmlControls;
using System.Web.UI;
using Formsy.Config;
using Formsy.Common;

namespace Formsy.Providers.CustomField
{
    public class StandardProvider : CustomFieldProvider
    {
        public override void Initialize(string name, NameValueCollection config)
        {
            base.Initialize(name, config);
        }


        /// <summary>
        /// Adds a new HtmlGenericControl to the fieldSet.
        /// </summary>
        /// <returns></returns>
        public override HtmlGenericControl CreateCustomField(XElement field, HtmlGenericControl div, HtmlGenericControl fieldSet, List<FormField> formFields)
        {
            string name = field.GetName();
            HtmlGenericControl newDiv = new HtmlGenericControl("div");
            LiteralControl l = new LiteralControl("This a the Custom Field message");
            l.ID = ControlBuilderHelper.CreateId(ControlType.Literal, name);
            
            newDiv.Controls.Add(l);

            formFields.Add(new FormField(l.ID, name, l, null, ControlType.Literal, false));
            fieldSet.Controls.Add(newDiv);
            return newDiv;
        }

    }
}
